package com.eascs.ticket.project.controller;

import java.util.List;

import javax.inject.Inject;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.eascs.site.controller.BaseRestController;
import com.eascs.site.view.HtmlRestResult;
import com.eascs.site.view.MessageRestResult;
import com.eascs.site.view.ViewContext;
import com.eascs.ticket.project.form.AddProjectTicketTypeForm;
import com.eascs.ticket.project.form.GetNotSelectTicketTypeForm;
import com.eascs.ticket.project.form.RemoveProjectTicketTypeForm;
import com.eascs.ticket.project.service.ProjectTicketTypeService;

@RestController
public class ProjectTicketTypeRestController extends BaseRestController {
	@Inject
	private ProjectTicketTypeService projectTicketTypeService;

	@RequestMapping(value = "/project/ticket-type/remove")
	public MessageRestResult removeProjectTicketType(RemoveProjectTicketTypeForm removeProjectTicketTypeForm) {
		projectTicketTypeService.removeTicketTypeById(removeProjectTicketTypeForm.getId());
		return MessageRestResult.info("操作成功").andRefresh();
	}

	@RequestMapping(value = "/project/ticket-type/add")
	public MessageRestResult addProjectTicketType(AddProjectTicketTypeForm addProjectTicketTypeForm) {
		projectTicketTypeService.insertProjectTicketType(addProjectTicketTypeForm.getProjectId(), addProjectTicketTypeForm.getTicketType());
		return MessageRestResult.info("操作成功").andRefresh();
	}

	@RequestMapping(value = "/project/ticket-type/list")
	public HtmlRestResult getNotSelectTicketType(GetNotSelectTicketTypeForm getNotSelectTicketTypeForm) {
		List<Object[]> getNotSelectTicketTypeDataSource = projectTicketTypeService.getNotSelectTicketTypeByProjectId(getNotSelectTicketTypeForm.getProjectId());
		ViewContext.put("getNotSelectTicketTypeDataSource", getNotSelectTicketTypeDataSource);
		ViewContext.put("projectId", getNotSelectTicketTypeForm.getProjectId());
		return HtmlRestResult.popHtmlFragment("project/getNotSelectTicketTypeByProjectCode");
	}

}
